package com.scs.application.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.scs.application.core.entity.DataEntity;
import com.scs.application.modules.upgrade.db.annotation.EntityClassAnnotation;
import com.scs.application.modules.upgrade.db.annotation.EntityFieldAnnotation;
import com.scs.application.modules.upgrade.db.enums.EntityFieldType;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * <p>
 * 定时任务
 * </p>
 */
@Data
@Accessors(chain = true)
@EntityClassAnnotation(remark = "定时任务表")
@TableName("sys_schedule_job")
public class ScheduleJob extends DataEntity {


    // id ,在父类中处理

    @EntityFieldAnnotation(
            text = "任务名称",
            length = "50",
            not_null = true,
            default_value = "",
            comment = "任务名称"
    )
    private String jobName;

    @EntityFieldAnnotation(
            text = "任务组名",
            length = "50",
            not_null = true,
            default_value = "",
            comment = "任务组名"
    )
    private String jobGroup;

    @EntityFieldAnnotation(
            text = "任务描述",
            length = "200",
            not_null = false,
            default_value = "",
            comment = "任务描述"
    )
    private String description;

    @EntityFieldAnnotation(
            text = "调用目标字符串",
            length = "200",
            not_null = true,
            default_value = "",
            comment = "调用目标字符串"
    )
    private String invokeTarget;

    @EntityFieldAnnotation(
            text = "周期表达式。例：0 0/5 * * * ?  ",
            length = "200",
            not_null = true,
            default_value = "",
            comment = " 周期表达式"
    )
    private String cronExpression;

    @EntityFieldAnnotation(
            text = "计划错误策略。1：不立刻执行，等待下次周期到达再执行，2：以当前时间立刻执行，之后按周期执行 ",
            length = "",
            not_null = true,
            default_value = "0",
            comment = " 计划错误策略"
    )
    private Integer misfireInstruction;

    @EntityFieldAnnotation(
            text = "是否并发执行",
            length = "",
            not_null = true,
            default_value = "0",
            comment = "是否并发执行"
    )
    private Boolean flagConcurrent;

    @EntityFieldAnnotation(
            text = "任务执行状态",
            length = "10",
            not_null = true,
            default_value = "not_run",
            comment = "not_run:未启动,定时器未启动或者手动关闭了定时器，not_exec：定时器已启动，但是该任务尚未执行，即：还没有到达该任务的执行周期，exec：定时器已启动，该任务正在执行中，即：到达执行周期后对应业务方法正在处理中，pause：暂停:，定时器已启动，该任务已暂停"
    )
    private String statusExecution;

    @EntityFieldAnnotation(
            text = "任务执行状态变化时间",
            length = "",
            not_null = false,
            comment = "即statusExecution发生变化的时间"
    )
    private Date statusExecutionDate;


    /** 下次执行时间 */
    @EntityFieldAnnotation(
            text = "下次执行时间",
            length = "",
            not_null = false,
            comment = "下次执行时间"
    )
    private Date nextFireTime;

    @EntityFieldAnnotation(
            text = "是否启用",
            length = "",
            not_null = false,
            default_value = "0",
            comment = "启用"
    )
    private Boolean flagEnabled;

    @EntityFieldAnnotation(
            text = "任务上次执行时间",
            length = "",
            not_null = false,
            default_value = "",
            comment = "任务上次执行时间，调用业务处理之后进行更新"
    )
    private Date lastDate;

    @EntityFieldAnnotation(
            text = "任务上次成功执行时间",
            length = "",
            not_null = false,
            default_value = "",
            comment = "任务上次成功执行时间，调用业务处理成功之后进行更新"
    )
    private Date lastSuccessDate;

    @EntityFieldAnnotation(
            text = "任务上次执行结果",
            length = "4",
            not_null = false,
            default_value = "",
            comment = "1：成功，0：失败"
    )
    private String lastStatus;

    @EntityFieldAnnotation(
            text = "任务上次执行描述",
            not_null = false,
            type = EntityFieldType.LONGTEXT,
            comment = "成功或者失败信息"
    )
    private String lastRemark;
}
